/********************************************************************
	TABAL ENGINE - 2012/11/09
	author:		Marc Cuscullola
	
	purpose:	Defines the manager for all the input devices
*********************************************************************/
#pragma once

#ifndef __INPUT_MANAGER__INCLUDED_H__
#define __INPUT_MANAGER__INCLUDED_H__

#include "InputDefs.h"
#include "Vector\Vector2.h"
#include "MathTypes.h"
#include "Singleton/Singleton.h"
#include <windows.h>
#include <dinput.h>
#include <string>
#include <vector>
#include <map>

class CMouse;
class CKeyboard;

#define INPUT CInputManager::GetSingletonPtr()

class CInputManager : public CSingleton<CInputManager>
{
public:
	CInputManager();
	~CInputManager();

	bool	Initialize	(HWND _hWnd, Vect2u _screenSize);
	void	Uninitialize();

	bool	Load		(const std::string& _filename);
	bool	Reload		();

	void	Update		();

	// Action Methods
	bool	DoAction	(const std::string &_action);
	bool	DoAction	(const std::string &_action, float& delta_);

private:
	bool	LoadFile	();
	void	CleanUp		();

	void	InitCodeMap	();
	void	InitNameMap	();

	bool	IsDown		(Input::INPUT_DEVICE_TYPE _device, uint32 _uBtn);
	bool	IsDownUp	(Input::INPUT_DEVICE_TYPE _device, uint32 _uBtn);
	bool	IsUpDown	(Input::INPUT_DEVICE_TYPE _device, uint32 _uBtn);

private:
	LPDIRECTINPUT8	m_DirectInput;
	CMouse*			m_pMouse;
	CKeyboard*		m_pKeyboard;

	std::string		m_sFilename;

	typedef std::map<std::string, std::vector<Input::SInputInfo*>> TMapActions;

	TMapActions							m_ActionsMap;
	std::map<std::string, uint32>		m_CodeMap;
	std::map<std::string, std::string>	m_NameMap;
};

#endif //__INPUT_MANAGER__INCLUDED_H__